import weui from 'weui.js'

export function address(options) {
  return new Promise((resolve, reject) => {
    if (options.length < 1) {
      reject('地区列表不可为空')
    }
    let value = []
    let label = ''
    weui.picker(options, {
      container: 'body',
      onConfirm: function (result) {
        result.forEach(item => {
          label += item.label + '/'
          value.push(item.value)
        })
        label = label.substr(0, label.length - 1)
        resolve({value, label})
      }
    })
  })
}